<template>
  <el-menu router :default-active="$route.path" class="el-menu-vertical-demo" background-color="#334157" text-color="#fff "
    @open="handleOpen" @close="handleClose" active-text-color="#ffd04b" :collapse="collapsed" :collapse-transition="bb">
    <!-- <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b"> -->
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>
    <el-submenu v-for="node1 in treeNodeList" :index="node1.url?node1.url:node1.menuId">
      <template slot="title">
        <i :class="node1.icon"></i>
        <span>{{node1.name}}</span>
      </template>

      <el-menu-item v-for="node2 in node1.children" :index="node2.url?node2.url:node2.menuId">
        <i :class="node2.icon"></i>
        <span slot="title">{{node2.name}}</span>
      </el-menu-item>

     <!-- <el-menu-item v-for="node3 in node2.children" :index="node3.url?node3.url:node3.menuId">
        <i :class="node3.icon"></i>
        <span slot="title">{{node3.name}},{{node3.url?node3.url:node3.menuId}}</span>
      </el-menu-item> -->


    </el-submenu>
  </el-menu>
</template>
<script>
  export default {
    data: function() {
      return {
        collapsed: false,
        /*是否实现动画效果 */
        bb: true,
        treeNodeList: []
      }
    },
    beforeCreate: function() {
      this.$root.Bus.$on('aside-toggle', (collapsed) => {
        this.collapsed = collapsed;
      });

      //加载树节点
      this.axios.post(this.axios.urls.SYS_MENU_LIST,
        this.user
      ).then((response) => {
        let treeNodeList = response.data.result;
        console.log(treeNodeList);
        this.treeNodeList = treeNodeList;
      });

    },
    methods: {
      handleOpen(key, keyPath) {
        // console.log("handleOpen");
        // console.log(key);
        // console.log(keyPath);
      },
      handleClose(key, keyPath) {
        // console.log("handleOpen");
        // console.log(key);
        // console.log(keyPath);
      }
    }
  }
</script>
<style>
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 240px;
    min-height: 400px;
  }

  .el-menu-vertical-demo:not(.el-menu--collapse) {
    border: none;
    text-align: left;
  }

  .el-menu-item-group__title {
    padding: 0px;
  }

  .el-menu-bg {
    background-color: #1f2d3d !important;
  }

  .el-menu {
    border: none;
  }

  .logobox {
    height: 40px;
    line-height: 40px;
    color: #9d9d9d;
    font-size: 20px;
    text-align: center;
    padding: 20px 0px;
  }

  .logoimg {
    height: 40px;
  }
</style>
